package cloud.pangui.core.mongo.element;

/**
 * 排序
 * @Auther hepangui
 * @Date 2020/10/06 0001
*/
public class Order {

	/**
	 * 正序
	 */
	public static final int ASC = 1;

	/**
	 * 倒序
	 */
	public static final int DESC = -1;

	/**
	 * 键
	 */
	String key;

	/**
	 * 排序类型
	 */
	int type;

	private Order(String key, int type) {
		this.key = key;
		this.type = type;
	}

	/**
	 * 返回一个升序排列
	 * @param key
	 * @return
	 */
	public static Order asc(String key){
		return new Order(key,ASC);
	}

	/**
	 * 返回一个降序排列
	 * @param key
	 * @return
	 */
	public static Order desc(String key){
		return new Order(key,DESC);
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}
}
